home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl / 5.10.0 / Module / Build / Platform / MacOS.pm < prev    next >
Encoding:
Perl POD Document  |  2009-06-26  |  3.5 KB  |  153 lines

  1. package Module::Build::Platform::MacOS;
  2.  
  3. use strict;
  4. use vars qw($VERSION);
  5. $VERSION = '0.2808_01';
  6. $VERSION = eval $VERSION;
  7. use Module::Build::Base;
  8. use vars qw(@ISA);
  9. @ISA = qw(Module::Build::Base);
  10.  
  11. use ExtUtils::Install;
  12.  
  13. sub have_forkpipe { 0 }
  14.  
  15. sub new {
  16.   my $class = shift;
  17.   my $self = $class->SUPER::new(@_);
  18.   
  19.   # $Config{sitelib} and $Config{sitearch} are, unfortunately, missing.
  20.   foreach ('sitelib', 'sitearch') {
  21.     $self->config($_ => $self->config("install$_"))
  22.       unless $self->config($_);
  23.   }
  24.   
  25.   # For some reason $Config{startperl} is filled with a bunch of crap.
  26.   (my $sp = $self->config('startperl')) =~ s/.*Exit \{Status\}\s//;
  27.   $self->config(startperl => $sp);
  28.   
  29.   return $self;
  30. }
  31.  
  32. sub make_executable {
  33.   my $self = shift;
  34.   require MacPerl;
  35.   foreach (@_) {
  36.     MacPerl::SetFileInfo('McPL', 'TEXT', $_);
  37.   }
  38. }
  39.  
  40. sub dispatch {
  41.   my $self = shift;
  42.  
  43.   if( !@_ and !@ARGV ) {
  44.     require MacPerl;
  45.       
  46.     # What comes first in the action list.
  47.     my @action_list = qw(build test install);
  48.     my %actions = map {+($_, 1)} $self->known_actions;
  49.     delete @actions{@action_list};
  50.     push @action_list, sort { $a cmp $b } keys %actions;
  51.  
  52.     my %toolserver = map {+$_ => 1} qw(test disttest diff testdb);
  53.     foreach (@action_list) {
  54.       $_ .= ' *' if $toolserver{$_};
  55.     }
  56.     
  57.     my $cmd = MacPerl::Pick("What build command? ('*' requires ToolServer)", @action_list);
  58.     return unless defined $cmd;
  59.     $cmd =~ s/ \*$//;
  60.     $ARGV[0] = ($cmd);
  61.     
  62.     my $args = MacPerl::Ask('Any extra arguments?  (ie. verbose=1)', '');
  63.     return unless defined $args;
  64.     push @ARGV, $self->split_like_shell($args);
  65.   }
  66.   
  67.   $self->SUPER::dispatch(@_);
  68. }
  69.  
  70. sub ACTION_realclean {
  71.   my $self = shift;
  72.   chmod 0666, $self->{properties}{build_script};
  73.   $self->SUPER::ACTION_realclean;
  74. }
  75.  
  76. # ExtUtils::Install has a hard-coded '.' directory in versions less
  77. # than 1.30.  We use a sneaky trick to turn that into ':'.
  78. #
  79. # Note that we do it here in a cross-platform way, so this code could
  80. # actually go in Module::Build::Base.  But we put it here to be less
  81. # intrusive for other platforms.
  82.  
  83. sub ACTION_install {
  84.   my $self = shift;
  85.   
  86.   return $self->SUPER::ACTION_install(@_)
  87.     if eval {ExtUtils::Install->VERSION('1.30'); 1};
  88.     
  89.   local $^W = 0; # Avoid a 'redefine' warning
  90.   local *ExtUtils::Install::find = sub {
  91.     my ($code, @dirs) = @_;
  92.  
  93.     @dirs = map { $_ eq '.' ? File::Spec->curdir : $_ } @dirs;
  94.  
  95.     return File::Find::find($code, @dirs);
  96.   };
  97.   
  98.   return $self->SUPER::ACTION_install(@_);
  99. }
  100.  
  101. 1;
  102. __END__
  103.  
  104. =head1 NAME
  105.  
  106. Module::Build::Platform::MacOS - Builder class for MacOS platforms
  107.  
  108. =head1 DESCRIPTION
  109.  
  110. The sole purpose of this module is to inherit from
  111. C<Module::Build::Base> and override a few methods.  Please see
  112. L<Module::Build> for the docs.
  113.  
  114. =head2 Overriden Methods
  115.  
  116. =over 4
  117.  
  118. =item new()
  119.  
  120. MacPerl doesn't define $Config{sitelib} or $Config{sitearch} for some
  121. reason, but $Config{installsitelib} and $Config{installsitearch} are
  122. there.  So we copy the install variables to the other location
  123.  
  124. =item make_executable()
  125.  
  126. On MacOS we set the file type and creator to MacPerl so it will run
  127. with a double-click.
  128.  
  129. =item dispatch()
  130.  
  131. Because there's no easy way to say "./Build test" on MacOS, if
  132. dispatch is called with no arguments and no @ARGV a dialog box will
  133. pop up asking what action to take and any extra arguments.
  134.  
  135. Default action is "test".
  136.  
  137. =item ACTION_realclean()
  138.  
  139. Need to unlock the Build program before deleting.
  140.  
  141. =back
  142.  
  143. =head1 AUTHOR
  144.  
  145. Michael G Schwern <schwern@pobox.com>
  146.  
  147.  
  148. =head1 SEE ALSO
  149.  
  150. perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
  151.  
  152. =cut
  153.